package com.luu.game.service.impl;

import com.luu.game.dao.UserElfDao;
import com.luu.game.data.dto.ElfInfoDTO;
import com.luu.game.data.dto.UserElfSkillDTO;
import com.luu.game.data.entity.UserElfEntity;
import com.luu.game.service.UserElfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserElfServiceImpl implements UserElfService {

    @Autowired
    private UserElfDao userElfDao;

    @Override
    public List<UserElfEntity> findAll() {
        return userElfDao.findAll();
    }

    @Override
    public ElfInfoDTO findById(Integer id) {
        return userElfDao.findById(id);
    }

    /**
     * 判断角色精灵是否有该技能
     * @param userElfId
     * @param skId
     * @return
     */
    @Override
    public boolean isHaveSkill(Integer userElfId, Integer skId) {

        final UserElfSkillDTO userElfSkillDTO = userElfDao.findByUserElfIdAndSkId(userElfId, skId);

        if (userElfSkillDTO != null){
            return true;
        }

        return false;
    }

    @Override
    public void updateUserElfInfo(ElfInfoDTO elfInfoDTO) {
        userElfDao.update(elfInfoDTO);
    }


}
